package com.muyu.system.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.system.domain.DanmoShoppingSpecification;
import com.muyu.system.req.DanmoSpecificationDto;
import com.muyu.system.service.IDanmoShoppingSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品规格Controller
 * 
 * @author kunzong
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/DanmoShoppingSpecification")
public class DanmoShoppingSpecificationController extends BaseController
{
    @Autowired
    private IDanmoShoppingSpecificationService danmoShoppingSpecificationService;

    /**
     * 查询商品规格列表
     */
//    @RequiresPermissions("system:DanmoShoppingSpecification:list")
    @PostMapping("/list")
    public Result list(@RequestBody DanmoSpecificationDto danmoSpecificationDto)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (loginUser == null) {
            return Result.warn("请登录");
        }

        return danmoShoppingSpecificationService.selectDanmoShoppingSpecificationList(danmoSpecificationDto);
    }

    /**
     * 导出商品规格列表
     */
//    @RequiresPermissions("system:DanmoShoppingSpecification:export")
/*    @Log(title = "商品规格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoShoppingSpecification danmoShoppingSpecification)
    {
        List<DanmoShoppingSpecification> list = danmoShoppingSpecificationService.selectDanmoShoppingSpecificationList(danmoShoppingSpecification);
        ExcelUtil<DanmoShoppingSpecification> util = new ExcelUtil<DanmoShoppingSpecification>(DanmoShoppingSpecification.class);
        util.exportExcel(response, list, "商品规格数据");
    }*/

    /**
     * 获取所选商品商品规格详细信息
     */
//    @RequiresPermissions("system:DanmoShoppingSpecification:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoShoppingSpecificationService.selectDanmoShoppingSpecificationById(id));
    }

    /**
     * 新增商品规格
     */
//    @RequiresPermissions("system:DanmoShoppingSpecification:add")
    @Log(title = "商品规格", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoShoppingSpecification danmoShoppingSpecification)
    {
        return Result.success(danmoShoppingSpecificationService.insertDanmoShoppingSpecification(danmoShoppingSpecification));
    }

    /**
     * 修改商品规格
     */
//    @RequiresPermissions("system:DanmoShoppingSpecification:edit")
    @Log(title = "商品规格", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoShoppingSpecification danmoShoppingSpecification)
    {
        return Result.success(danmoShoppingSpecificationService.updateDanmoShoppingSpecification(danmoShoppingSpecification));
    }

    /**
     * 删除商品规格
     */
//    @RequiresPermissions("system:DanmoShoppingSpecification:remove")
    @Log(title = "商品规格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoShoppingSpecificationService.deleteDanmoShoppingSpecificationByIds(ids));
    }
}
